//
//  BaseImgViewController.m
//  HTHappySale
//
//  Created by 曾华桥 on 17/9/26.
//  Copyright © 2017年 zxyywy. All rights reserved.
//

#import "BaseImgViewController.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "Constants.h"
#import "MainViewController.h"
@interface BaseImgViewController ()

@property(nonatomic,strong)UIImageView *imgView;
@end

@implementation BaseImgViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addSubViews];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self addNavigationLeftView:@"" andType:0];
    MainViewController *mainCtrol = (MainViewController *)self.tabBarController;
    [mainCtrol hiddenTabBarWeb];
}

-(void)addSubViews{
    _imgView = [[UIImageView alloc] init];
    _imgView.contentMode = UIViewContentModeScaleAspectFit;
    [self.view addSubview:_imgView];
}

-(void)loadImage:(NSString *)urlStr{
    NSURL *imgUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",Img_URL,urlStr]];
    [self.imgView sd_setImageWithURL:imgUrl];
    SDWebImageManager *manager = [SDWebImageManager sharedManager];
    BOOL existBool = [manager diskImageExistsForURL:imgUrl];//判断是否有缓存
    UIImage * image;
    if (existBool) {
        image = [[manager imageCache] imageFromDiskCacheForKey:imgUrl.absoluteString];
    }else{
        NSData *data = [NSData dataWithContentsOfURL:imgUrl];
        image = [UIImage imageWithData:data];
    }
    self.imgView.frame = CGRectMake(0, 0, image.size.width, image.size.height);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}


@end
